<?php
/**
 * Created by PhpStorm.
 * User: wz
 * Date: 2018/7/31
 * Time: 0:23
 */

namespace App\Http\Controllers\Admin;

use App\Base\BaseFunc;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;

class YouController extends Controller
{
    public function searchGameMap()
    {
        $data['gameMapData'] = DB::table('game_map')
            ->orderby('game_map_id','desc')
            ->paginate(10);
        session(['now_address'=>'/searchGameMap']);
        return view('/admin.you.searchGameMap',$data);
    }

    public function addGameMap(BaseFunc $baseFunc)
    {
        $input = Input::only('game_map_name','game_map_info','game_map_floor');
        $input['game_map_time'] = date('Y-m-d H:i:s');
        DB::table('game_map')->insert($input);
        $baseFunc->setRedirectMessage(true,"添加游戏地图成功！",NULL,"/searchGameMap");
    }

    public function gameMapInfo($id)
    {
        $data['gameMapData'] = DB::table('game_map')
            ->where('game_map_id',$id)
            ->first();
        return view('/admin.you.gameMapInfo',$data);
    }

    public function delGameMap(BaseFunc $baseFunc)
    {
        $input = Input::only('game_map_id');
        $data = DB::table('game_map')
            ->where('game_map_id','=',$input['game_map_id'])
            ->delete();
        if($data)
        {
            $baseFunc->setRedirectMessage(true,'删除成功',NULL,'/searchGameMap');
        }
        else
        {
            $baseFunc->setRedirectMessage(false,'删除失败',NULL,'/searchGameMap');
        }
    }

    public function searchGameBoss()
    {
        $data['gameBossData'] = DB::table('game_boss')
            ->orderby('game_boss_id','desc')
            ->paginate(10);
        session(['now_address'=>'/searchGameBoss']);
        return view('/admin.you.searchGameBoss',$data);
    }

    public function addGameBoss(BaseFunc $baseFunc)
    {
        $input = Input::only('game_boss_name','game_boss_info','game_boss_floor');
        $input['game_boss_time'] = date('Y-m-d H:i:s');
        DB::table('game_boss')->insert($input);
        $baseFunc->setRedirectMessage(true,"添加游戏怪物成功！",NULL,"/searchGameBoss");
    }

    public function gameBossInfo($id)
    {
        $data['gameBossData'] = DB::table('game_boss')
            ->where('game_boss_id',$id)
            ->first();
        return view('/admin.you.gameBossInfo',$data);
    }

    public function delGameBoss(BaseFunc $baseFunc)
    {
        $input = Input::only('game_boss_id');
        $data = DB::table('game_boss')
            ->where('game_boss_id','=',$input['game_boss_id'])
            ->delete();
        if($data)
        {
            $baseFunc->setRedirectMessage(true,'删除成功',NULL,'/searchGameBoss');
        }
        else
        {
            $baseFunc->setRedirectMessage(false,'删除失败',NULL,'/searchGameBoss');
        }
    }

    public function searchGameNPC()
    {
        $data['gameNPCData'] = DB::table('game_npc')
            ->orderby('game_npc_id','desc')
            ->paginate(10);
        session(['now_address'=>'/searchGameNPC']);
        return view('/admin.you.searchGameNPC',$data);
    }

    public function addGameNPC(BaseFunc $baseFunc)
    {
        $input = Input::only('game_npc_name','game_npc_info','game_npc_floor');
        $input['game_npc_time'] = date('Y-m-d H:i:s');
        DB::table('game_npc')->insert($input);
        $baseFunc->setRedirectMessage(true,"添加游戏NPC成功！",NULL,"/searchGameNPC");
    }

    public function gameNPCInfo($id)
    {
        $data['gameNPCData'] = DB::table('game_npc')
            ->where('game_npc_id',$id)
            ->first();
        return view('/admin.you.gameNPCInfo',$data);
    }

    public function delGameNPC(BaseFunc $baseFunc)
    {
        $input = Input::only('game_npc_id');
        $data = DB::table('game_npc')
            ->where('game_npc_id','=',$input['game_npc_id'])
            ->delete();
        if($data)
        {
            $baseFunc->setRedirectMessage(true,'删除成功',NULL,'/searchGameNPC');
        }
        else
        {
            $baseFunc->setRedirectMessage(false,'删除失败',NULL,'/searchGameNPC');
        }
    }

    public function searchGameSkill()
    {
        $data['gameSkillData'] = DB::table('game_skill')
            ->orderby('game_skill_id','desc')
            ->paginate(10);
        session(['now_address'=>'/searchGameSkill']);
        return view('/admin.you.searchGameSkill',$data);
    }

    public function addGameSkill(BaseFunc $baseFunc)
    {
        $input = Input::only('game_skill_name','game_skill_info','game_skill_floor');
        $input['game_skill_time'] = date('Y-m-d H:i:s');
        DB::table('game_skill')->insert($input);
        $baseFunc->setRedirectMessage(true,"添加游戏武功成功！",NULL,"/searchGameSkill");
    }

    public function gameSkillInfo($id)
    {
        $data['gameSkillData'] = DB::table('game_skill')
            ->where('game_skill_id',$id)
            ->first();
        return view('/admin.you.gameSkillInfo',$data);
    }

    public function delGameSkill(BaseFunc $baseFunc)
    {
        $input = Input::only('game_skill_id');
        $data = DB::table('game_skill')
            ->where('game_skill_id','=',$input['game_skill_id'])
            ->delete();
        if($data)
        {
            $baseFunc->setRedirectMessage(true,'删除成功',NULL,'/searchGameSkill');
        }
        else
        {
            $baseFunc->setRedirectMessage(false,'删除失败',NULL,'/searchGameSkill');
        }
    }

    public function searchGameZB()
    {
        $data['gameZBData'] = DB::table('game_zb')
            ->orderby('game_zb_id','desc')
            ->paginate(10);
        session(['now_address'=>'/searchGameZB']);
        return view('/admin.you.searchGameZB',$data);
    }

    public function addGameZB(BaseFunc $baseFunc)
    {
        $input = Input::only('game_zb_name','game_zb_info','game_zb_floor');
        $input['game_zb_time'] = date('Y-m-d H:i:s');
        DB::table('game_zb')->insert($input);
        $baseFunc->setRedirectMessage(true,"添加游戏装备成功！",NULL,"/searchGameZB");
    }

    public function gameZBInfo($id)
    {
        $data['gameZBData'] = DB::table('game_zb')
            ->where('game_zb_id',$id)
            ->first();
        return view('/admin.you.gameZBInfo',$data);
    }

    public function delGameZB(BaseFunc $baseFunc)
    {
        $input = Input::only('game_zb_id');
        $data = DB::table('game_zb')
            ->where('game_zb_id','=',$input['game_zb_id'])
            ->delete();
        if($data)
        {
            $baseFunc->setRedirectMessage(true,'删除成功',NULL,'/searchGameZB');
        }
        else
        {
            $baseFunc->setRedirectMessage(false,'删除失败',NULL,'/searchGameZB');
        }
    }
}